#coding=utf-8
import requests
import json


def check_ip(ip, port = None):
    targetUrl = "https://ip.tool.chinaz.com/"

    # 代理服务器
    proxyHost = "ip"
    proxyPort = "port"

    proxyMeta = "https://%(host)s:%(port)s" % {
        "host": ip,
        "port": port
    }

    proxies = {
        "http": proxyMeta,
        "https": proxyMeta
    }

    res = requests.get(targetUrl, proxies = proxies)

    status_code = res.status_code
    print(status_code)
    if status_code == 200:
        return True
    else:
        return False

check_ip('47.104.213.89','4111')

# ip = requests.get('http://d.jghttp.golangapi.com/getip?num=100&type=2&pro=0&city=0&yys=0&port=1&pack=29622&ts=0&ys=0&cs=0&lb=1&sb=0&pb=4&mr=1&regions=');
#
# data = json.loads(ip.text)
#
# if data['success'] == True:
#     ip_pool = data['data']
#
#     for ip in ip_pool:
#         print(ip)